// pages/evaluate/evalute.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    stars: [{
      lightImg: '../../photos/sadff.png',
      blackImg: '../../photos/xinsg.png',
      flag: 1,
      message: '非常不满意，各方面都很差'
     }, {
       lightImg: '../../photos/sadff.png',
       blackImg: '../../photos/xinsg.png',
      flag: 1,
      message: '不满意，比较差'
     }, {
       lightImg: '../../photos/sadff.png',
       blackImg: '../../photos/xinsg.png',
      flag: 1,
      message: '一般，还要改善'
     }, {
       lightImg: '../../photos/sadff.png',
       blackImg: '../../photos/xinsg.png',
      flag: 1,
      message: '比较满意，仍要改善'
     }, {
       lightImg: '../../photos/sadff.png',
       blackImg: '../../photos/xinsg.png',
      flag: 1,
      message: '非常完美，无可挑剔'
     }],
     details:{},
     Listrige:{},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      details:JSON.parse(options.item)
    })
    this.selectOrderEvaluation();   //查看订单评价
  },


  // 查看订单评价
  selectOrderEvaluation:function(){
  wx.showLoading({
    title: '加载中',
  })
  wx.showNavigationBarLoading();
  var that = this;
  wx.request({
    url: getApp().url.dev + '/api/orders/selectOrderEvaluation/'+that.data.details.ordersId , //这里就写上后台解析手机号的接口
    //这里的几个参数是获取授权后的加密数据，作为参数传递给后台就行了
    data: {},
    method: 'get',
    header: {
      'content-type': 'application/x-www-form-urlencoded',
      'token': wx.getStorageSync("token"),
    },
    success(res) {
      console.log(res);
      wx.hideLoading()
      //隐藏导航条加载动画
      wx.hideNavigationBarLoading();
      //停止下拉刷新
      wx.stopPullDownRefresh();
      if (res.data.code == 200) {
        if(res.data.data.rate == 1){
          that.data.stars[0].flag = 1;
          that.data.stars[1].flag = 2;
          that.data.stars[2].flag = 2;
          that.data.stars[3].flag = 2;
          that.data.stars[4].flag = 2;
        }
        if(res.data.data.rate == 2){
          that.data.stars[0].flag = 1;
          that.data.stars[1].flag = 1;
          that.data.stars[2].flag = 2;
          that.data.stars[3].flag = 2;
          that.data.stars[4].flag = 2;
        }
        if(res.data.data.rate == 3){
          that.data.stars[0].flag = 1;
          that.data.stars[1].flag = 1;
          that.data.stars[2].flag = 1;
          that.data.stars[3].flag = 2;
          that.data.stars[4].flag = 2;
        }
        if(res.data.data.rate == 4){
          that.data.stars[0].flag = 1;
          that.data.stars[1].flag = 1;
          that.data.stars[2].flag = 1;
          that.data.stars[3].flag = 1;
          that.data.stars[4].flag = 2;
        }
        if(res.data.data.rate == 5){
          that.data.stars[0].flag = 1;
          that.data.stars[1].flag = 1;
          that.data.stars[2].flag = 1;
          that.data.stars[3].flag = 1;
          that.data.stars[4].flag = 1;
        }
        that.setData({
          Listrige:res.data.data,
          stars:that.data.stars
        })
      }else{
        wx.showToast({ title: res.data.msg,  icon:'none' })
      }
    }
  })
},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})